package cn.blnp.net.flowable.listen.exec;

import lombok.extern.slf4j.Slf4j;
import org.flowable.common.engine.api.delegate.Expression;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.ExecutionListener;
import org.springframework.stereotype.Component;

/**
 * <h3></h3>
 *
 * @author <a href="mailto:blnp.yibin@qq.com">lyb</a>
 * @version 1.0
 * @since 2025/5/21 10:18
 */
@Slf4j
@Component("myUserTaskExecutionListenerBean")
public class MyUserTaskExecutionListener implements ExecutionListener {

    /**
     *  配置属性值
     **/
    private Expression fixedValue;
    private Expression dynamicValue;

    @Override
    public void notify(DelegateExecution execution) {
        /**
         *  特别注意：如果有注入属性，必须得在对应实现类中先定义。否则将会抛出异常
         **/
        log.info("============通过class指定的监听器开始============");
        //获取节点唯一标识
        String activityId = execution.getCurrentActivityId();
        //获取事件名称
        String eventName = execution.getEventName();
        log.info("事件名称:" + eventName);
        log.info("activityId:" + activityId);
        log.info("fixedValue属性值为:" + fixedValue.getValue(execution));
        log.info("dynamicValue属性值为:" + dynamicValue.getValue(execution));
        log.info("============通过class指定的监听器结束============");
    }
}
